home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / e / kyz_obj.lha / doc / catalog.doc < prev    next >
Text File  |  1998-10-18  |  5KB  |  159 lines

  1. TABLE OF CONTENTS
  2.  
  3. catalog.m/--overview--
  4. catalog.m/def
  5. catalog.m/end
  6. catalog.m/get
  7. catalog.m/open
  8. catalog.m/--overview--                                 catalog.m/--overview--
  9.  
  10.    PURPOSE
  11.     To act as the base class for localized ID/string pairs.
  12.  
  13.    OVERVIEW
  14.     The  locale  library  contains  a  mechanism for isolating textual
  15.     strings  in  program  code (such as "OK", "Please select file" and
  16.     other  strings  for the benefit of the user) and allowing for them
  17.     to  be  changed  externally  from the program, while still holding
  18.     'default'  copies of the strings in the program core. This creates
  19.     the opportunity to have 'localized' strings.
  20.  
  21.     The default mechanism for this is with two 'catalog' files, Bla.cd
  22.     and Bla.ct, where the .cd file is the catalog of 'descriptors' and
  23.     the .ct file is a catalog of translations for a specific language.
  24.  
  25.     The .cd file contains your original text strings, and an uppercase
  26.     identifier for each of them. Example:
  27.  
  28.     MSG_OPEN_FILE (//)
  29.     Open file...
  30.  
  31.     The  identifier  is  translated into a numerical ID, and using the
  32.     'const' / 'define'  feature  of most programming languages, the ID
  33.     name is associated with that unique numerical value.
  34.  
  35.     When  you  wish  to use a string in your program, you would get it
  36.     from a function taking the ID and returning the string.
  37.  
  38.     filereq('Open file...')
  39.     BECOMES
  40.     filereq(get(MSG_OPEN_FILE))
  41.  
  42.     What  the  catalog_obj does is represent the catalog as an object,
  43.     thereby allowing you easy use of multiple catalogs, and using even
  44.     single  catalogs  very  easily. The general mechanism for actually
  45.     using  catalogs  is to subclass the bare catalog object and set up
  46.     default preset values - catalog name, builtin strings, language of
  47.     builtin strings, and possibly version.
  48.  
  49.    EXAMPLE
  50.     See the included example files showing a localised 'helloworld'.
  51.  
  52.     A  FlexCat  '.sd'  file,  included and used by the example, can be
  53.     used for automatic generation of compiled catalog modules from .cd
  54.     files.
  55.  
  56. catalog.m/def                                                   catalog.m/def
  57.  
  58.    NAME        
  59.     catalog_obj.def() -- Set up the default strings block.
  60.  
  61.    SYNOPSIS
  62.     def(block:PTR TO LONG)
  63.  
  64.    FUNCTION
  65.     Set the catalog's block of default strings. This is best kept as a
  66.     static  list with constants and static strings in it - the catalog
  67.     neither  copies  the strings nor the block into its own memory, it
  68.     uses the block and strings direct from whatever you pass it.
  69.  
  70.    INPUTS
  71.     block - a list containing ID/string pairs, see the example below.
  72.  
  73.    EXAMPLE
  74.     CONST MSG_HELLO=100, MSG_BYE=101
  75.     catalog.def([
  76.       MSG_HELLO, 'Hello',
  77.       MSG_BYE',  'Bye'
  78.     ])
  79.  
  80.    NOTE
  81.     The block _must_ be terminated with a long containing NIL. Amiga E
  82.     does  this  automatically  when you use the list operator, but not
  83.     when  you  use  the builtin-assembler 'LONG' directive, or magic a
  84.     list up yourself.
  85.  
  86.     In other words, just use this as shown and you'll be fine.
  87.  
  88.    SEE ALSO
  89.     get()
  90.  
  91. catalog.m/end                                                   catalog.m/end
  92.  
  93.    NAME
  94.     catalog_obj.end() -- Destructor.
  95.  
  96.    SYNOPSIS
  97.     end()
  98.  
  99.    FUNCTION
  100.     Frees resources used by an instance of the catalog_obj class.
  101.  
  102. catalog.m/get                                                   catalog.m/get
  103.  
  104.    NAME
  105.     catalog_obj.get() -- Get a localized message string.
  106.  
  107.    SYNOPSIS
  108.     string := get(id)
  109.  
  110.    FUNCTION
  111.     Attempts  to  retrieve  a  string from the opened catalog with the
  112.     requested  ID value. If not in the catalog, it will look for it in
  113.     the  block of default strings. If not there either, it will return
  114.     NIL.
  115.  
  116.    INPUTS
  117.     id - the ID value associated with the required string.
  118.  
  119.    RESULT
  120.     string - the  requested  string,  possibly  translated,  or NIL if
  121.              there is no such string available.
  122.  
  123. catalog.m/open                                                 catalog.m/open
  124.  
  125.    NAME
  126.     catalog_obj.open() -- Constructor.
  127.  
  128.    SYNOPSIS
  129.     open(catalog, language, locale:PTR TO locale)
  130.  
  131.    FUNCTION
  132.     Creates an instance of the catalog class. Opens the locale library
  133.     and appropriate translations of the catalog as neccesary.
  134.  
  135.     As  no  minimum  level  of  allocations  are  necessary to operate
  136.     correctly, this constructor throws no exceptions.
  137.  
  138.     Apart from calling this constructor, you should also call def() to
  139.     set up default strings before starting to call get().
  140.  
  141.    INPUTS
  142.     catalog  - The  name  of  the catalog containing your strings, for
  143.                example 'helloworld.catalog'. Must not be NIL.
  144.  
  145.     language - A  string  representing the name of the language of the
  146.                default strings you supply - for example, 'français' or
  147.                'deutsch'.  If  the language of the defaults strings is
  148.                'english', you can pass NIL instead.
  149.  
  150.     locale -   If  you  are  using  a particular locale structure from
  151.                OpenLocale(),  you  may  pass  this  in  to  affect the
  152.                opening and parsing of the catalog. If you just want to
  153.                use  the default locale (user's preference) then simply
  154.                pass NIL.
  155.  
  156.    SEE ALSO
  157.     locale.library/OpenCatalog(), def()
  158.  
  159.